/**
 * Bakalarska prace - Inteligentni budik
 * @package sleepCatcher
 * @file SCSession.h
 * @author Jan Pesava - xpesav00
 * @email xpesav00@stud.fit.vutbr.cz
 * @date 24. 12. 2011
 */

#ifndef SCSESSION_H_
#define SCSESSION_H_

#include <FMedia.h>
#include <FGraphics.h>

#include "models/SCBaseModel.h"
#include "models/SCWindow.h"
#include "models/SCSample.h"
#include "models/SCAlarm.h"

using namespace Osp::Media;
using namespace Osp::Graphics;

class SCSession : public SCBaseModel
{

// Construct
public:
	SCSession();
	SCSession(int id);
	virtual ~SCSession();
	result Construct();

// Constants
public:
	static const int IDA_SESSION_TYPE_JUST_ANALYZE			= 200;
	static const int IDA_SESSION_TYPE_ANALYZE_AND_WAKEUP	= 201;

// Attributes
private:
	int type;
	DateTime startDate;
	DateTime endDate;
	DateTime stopDate;
	int qualityOfSleep;
	int samplesCount;
	Bitmap* pSleepGraph;
	SCWindow* pWindowProbe;
	ArrayList* pMaxExtrems;
	ArrayList* pMinExtrems;
	ArrayList* pCollectedSamples;
	Queue *pGraphWindow;
	int graphWindowMaxSize;
	float graphWindowEnergy;
	float graphWindowMaxEnergy;
	SCAlarm* pActiveAlarm;

// Methods
public:
	void SetType(int type);
	int GetType();
	DateTime GetStartDate();
	void SetStartDate(DateTime dateTime);
	DateTime GetEndDate();
	void SetEndDate(DateTime dateTime);
	DateTime GetStopDate();
	void SetStopDate(DateTime dateTime);
	SCAlarm* GetActiveAlarm();
	void SetActiveAlarm(SCAlarm* pActiveAlarm);
	int GetQualityOfSleep();
	void SetQualityOfSleep(int quality);
	int GetSamplesCount();
	void SetSamplesCount(int count);
	SCWindow* GetWindowProbe();
	void SetWindowProbe(SCWindow *pWindow);
	ArrayList* GetMaxExtreme();
	void SetMaxExteme(ArrayList* pList);
	ArrayList* GetMinExtreme();
	void SetMinExteme(ArrayList* pList);
	ArrayList* GetAllSamples();
	void SetSleepGraph(Bitmap* pGraph);
	Bitmap* GetSleepGraph();
	void AddSample(SCSample* pSample);
	void DeleteSample(int id);
	bool IsAwakeTime();
	int GetAwakeTimeIn();
	void SetNextPart();
	int ComputeSleepPeriod();
	void AddMaxExtreme(SCSample* pSample);
	void AddMinExtreme(SCSample* pSample);
	SCSample* GetLastMaxExtreme();
	SCSample* GetLastMinExtreme();
	void CreateSleepGraph();
	SCSample* GetYetMaxPoint();
	bool IsSampleAdd(ArrayList* pList, SCSample* pSample);
	void SetDefaultValues();
	void SetStopInformation();
	bool Load();
	bool Save();
	void StopCatch();
	void StartCatch();
	Osp::Base::Collection::IList* CreatePointListN(int xOffset,	int yOffset);

// Statics
public:
	static void Delete(int id);
	static ArrayList* GetAllSessions();
	static SCSession* GetSession(int id = NULL);
	static SCSession* GetLastSession();
};

#endif /* SCSESSION_H_ */
